package com.itheima;

import javax.swing.*;
import java.io.File;

public class Rename {
    public static void renameFiles(String oldName, String newName) {
        File oldFile = new File(oldName);
        File parent=oldFile.getParentFile();
        if(parent!=null) {
            File newFile = new File(parent,newName);
            if(oldFile.renameTo(newFile)) {
                JOptionPane.showMessageDialog(null, "文件重命名成功");
            }
            else {
                JOptionPane.showMessageDialog(null,"文件重命名失败");
            }
        }

    }
}

